import java.io.*;
import java.util.*;


class Main {
    public static void main(String[] args) {
        // -输入
        Scanner input = new Scanner(System.in);

        // 1 接收输入
        int n = input.nextInt();
        int m = input.nextInt();
        int[][] arr = new int[n][m];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m ;j++) {
                arr[i][j] = input.nextInt();
            }
        }

        // 2 操作
        int[] start = new int[n];
        int q = input.nextInt();
        for(int i = 0; i < q; i++) {
            int opt = input.nextInt();
            int row = input.nextInt() - 1;
            int k = input.nextInt();
            if(opt == 1) {
                start[row] += k;
            } else if(opt == 2) {
                start[row] -= k;
            }
        }

        // 3 输出
        for(int i = 0; i < n; i++) {
            int begin = start[i] % m;
            if(begin < 0) {
                // 在这里栽跟头，真的不应该啊！！！少做一题
                begin = m + begin;
            }
            for(int j = begin; j < m; j++) {
                System.out.print(arr[i][j] + " ");
            }
            for(int k = 0; k < begin; k++) {
                System.out.print(arr[i][k] + " ");
            }
            System.out.println();
        }
    }
}